3.1 - dnSpy general usage
What is dnSpy used for?
dnSpy is a tool which let us look into the game code while it's closed, to see how it does stuff and also expand our modding capabilities. With patch 07 of the game (release of Dedicated servers), the source code of the game was leaked, so we can now see the game code up to that patch using tools like dnSpy.
If you haven't already downloaded dnSpy, download it from here and extract the zip content inside another folder. To launch it, double click dnSpy.exe, you will see a window similar to the below.
Loading the game code
in dnSpy
First, we need to get the leaked source code dll's (you can ask for them in the sotf discord or find them yourself). Then, on the top left of dnSpy, click on File, then Open... and browse to where the leaked source code dll's are. Do CTRL+A to select all of them and press Open at the bottom right corner to load them.
Done, we have loaded the game code inside dnSpy as you can see in the image below.
Finding the first mod stuff
To make it clear how it works, lets find what we used to make the change player speed mod.
On the bottom you can see a searchbar and a Search for:
filter. If not already, set it to Class and All Files.
Type LocalPlayer
in the searchbox and you will see a list of results.
We are only interested in the first one, so double click on it to navigate to it.
On the left panel, expand the LocalPlayer dropdown menu and you will see a list of things related to it, some self explanatory.
If you scroll down a bit, you can see our FpCharacter we used to make our first mod.
Now click on it, and on the right panel click on FirstPersonCharacter to navigate to it.
Expand the FirstPersonCharacter dropdown menu on the left panel as we did with the LocalPlayer and you will see all the stuff related to the FirstPersonCharacter. If you scroll down a bit, you will see ours SetWalkSpeed and SetRunSpeed methods we used before to make the mod.
Summing up
dnSpy as UnityExplorer is a powerfull tool which let us investigate into the game code, with the difference that we can use it while the game is closed and so we can't do changes to the game. It may also act as a source of mod inspiration, since we can just look into the game code and see what we can create with it. In fact, if you look widely into the FirstPersonCharacter, you can see there are a lot of other methods we can use to create a mod other than SetWalkSpeed and SetRunSpeed (e.g SetSuperJump). Next lesson we are gonna setup a mod to change the player health and stamina.